package com.myshiro.service;

import com.myshiro.pojo.SysUser;
import com.myshiro.repository.SysUserRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SysUserServiceImpl implements SysUserService{

    @Resource
    SysUserRepository userRepository;

    public SysUser getByUsrName(String usrName){
        return userRepository.getByUsrName(usrName);
    }

    @Override
    public SysUser login(String usrName,String password) {
        SysUser currUser = getByUsrName(usrName);
        if (null !=currUser){
            if (password.equals(currUser.getUsrPassword())){
                return currUser;
            }
        }
        return null;
    }

    @Override
    public SysUser login(String usrName) {
        SysUser currUser = getByUsrName(usrName);
        return (null==currUser)?null:currUser;
    }
}
